API: window: Remove suppport for changing wmclass_name/group
authorBenjamin Otte <otte@redhat.com>
Thu, 29 Sep 2016 20:23:51 +0000 (22:23 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 16 Oct 2016 16:17:21 +0000 (18:17 +0200)
X11 was the only backend to support it and people can just override it
using XSetClassHint() directly.
The docs already advertised the function as "Do not use".

Keep the existing call to XSetClassHint() in place, so that we keep
setting the same values as in GTK3.

gdk/gdkwindow.h
gdk/win32/gdkwindow-win32.c
gdk/x11/gdkwindow-x11.c
gtk/gtkplug.c
gtk/gtkwin32embedwidget.c
gtk/gtkwindow.c
gtk/gtkwindow.h
gtk/gtkwindowprivate.h

index 869249926809ef8433e62e104fcd6ecaf67827a2..c3f13b4a0435fe489641ea35c724a0e2a528b3f1 100644 (file)
@@ -93,7 +93,6 @@ typedef enum
  * @GDK_WA_Y: Honor the Y coordinate field
  * @GDK_WA_CURSOR: Honor the cursor field
  * @GDK_WA_VISUAL: Honor the visual field
- * @GDK_WA_WMCLASS: Honor the wmclass_class and wmclass_name fields
  * @GDK_WA_NOREDIR: Honor the override_redirect field
  * @GDK_WA_TYPE_HINT: Honor the type_hint field
  *
@@ -111,9 +110,8 @@ typedef enum
   GDK_WA_Y        = 1 << 3,
   GDK_WA_CURSOR           = 1 << 4,
   GDK_WA_VISUAL           = 1 << 5,
-  GDK_WA_WMCLASS   = 1 << 6,
-  GDK_WA_NOREDIR   = 1 << 7,
-  GDK_WA_TYPE_HINT = 1 << 8
+  GDK_WA_NOREDIR   = 1 << 6,
+  GDK_WA_TYPE_HINT = 1 << 7
 } GdkWindowAttributesType;
 
 /* Size restriction enumeration.
@@ -343,8 +341,6 @@ typedef enum
  * @visual: #GdkVisual for window
  * @window_type: type of window
  * @cursor: cursor for the window (see gdk_window_set_cursor())
- * @wmclass_name: don’t use (see gtk_window_set_wmclass())
- * @wmclass_class: don’t use (see gtk_window_set_wmclass())
  * @override_redirect: %TRUE to bypass the window manager
  * @type_hint: a hint of the function of the window
  *
@@ -361,8 +357,6 @@ struct _GdkWindowAttr
   GdkVisual *visual;
   GdkWindowType window_type;
   GdkCursor *cursor;
-  gchar *wmclass_name;
-  gchar *wmclass_class;
   gboolean override_redirect;
   GdkWindowTypeHint type_hint;
 };
index 20ca3c35374702ef2c076308701cc14419bf3811..6d25baaeba072f2be1eb265ec0bd823a2bbe243a 100644 (file)
@@ -734,9 +734,9 @@ _gdk_win32_display_create_window_impl (GdkDisplay    *display,
       remaining_mask &= ~GDK_WA_NOREDIR;
     }
 
-  if ((remaining_mask & ~(GDK_WA_WMCLASS|GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
+  if ((remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT)) != 0)
     g_warning ("_gdk_window_impl_new: uexpected attribute 0x%X",
-               remaining_mask & ~(GDK_WA_WMCLASS|GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
+               remaining_mask & ~(GDK_WA_VISUAL|GDK_WA_CURSOR|GDK_WA_TITLE|GDK_WA_TYPE_HINT));
 
   hparent = GDK_WINDOW_HWND (real_parent);
 
@@ -752,10 +752,6 @@ _gdk_win32_display_create_window_impl (GdkDisplay    *display,
   impl->layered = FALSE;
   impl->layered_opacity = 1.0;
 
-  /* wclass is not any longer set always, but if is ... */
-  if ((attributes_mask & GDK_WA_WMCLASS) == GDK_WA_WMCLASS)
-    g_assert ((attributes->wclass == GDK_INPUT_OUTPUT) == !window->input_only);
-
   if (!window->input_only)
     {
       dwExStyle = 0;
index 14dfdd92552c7ec076b32c80b847ee0dcf444174..a954c46c474609979a6160323f8adfb888479eaa 100644 (file)
@@ -1127,14 +1127,11 @@ _gdk_x11_display_create_window_impl (GdkDisplay    *display,
 
       gdk_window_set_title (window, title);
 
-      if (attributes_mask & GDK_WA_WMCLASS)
-        {
-          class_hint = XAllocClassHint ();
-          class_hint->res_name = attributes->wmclass_name;
-          class_hint->res_class = attributes->wmclass_class;
-          XSetClassHint (xdisplay, impl->xid, class_hint);
-          XFree (class_hint);
-        }
+      class_hint = XAllocClassHint ();
+      class_hint->res_name = (char *) g_get_prgname ();
+      class_hint->res_class = (char *) gdk_get_program_class ();
+      XSetClassHint (xdisplay, impl->xid, class_hint);
+      XFree (class_hint);
 
       setup_toplevel_window (window, window->parent);
       break;
index 4e72543baafb49bbdf84912c70d766279c77803a..de56b4234d8e7a3bc825889c0e1c85cdb052aded 100644 (file)
@@ -1009,7 +1009,6 @@ gtk_plug_realize (GtkWidget *widget)
   GdkWindow *gdk_window;
   GdkWindowAttr attributes;
   const gchar *title;
-  gchar *wmclass_name, *wmclass_class;
   gint attributes_mask;
   GdkScreen *screen;
 
@@ -1020,13 +1019,10 @@ gtk_plug_realize (GtkWidget *widget)
     g_warning ("GtkPlug only works under X11");
 
   title = gtk_window_get_title (window);
-  _gtk_window_get_wmclass (window, &wmclass_name, &wmclass_class);
   gtk_widget_get_allocation (widget, &allocation);
 
   attributes.window_type = GDK_WINDOW_CHILD;   /* XXX GDK_WINDOW_PLUG ? */
   attributes.title = (gchar *) title;
-  attributes.wmclass_name = wmclass_name;
-  attributes.wmclass_class = wmclass_class;
   attributes.width = allocation.width;
   attributes.height = allocation.height;
   attributes.wclass = GDK_INPUT_OUTPUT;
@@ -1044,7 +1040,6 @@ gtk_plug_realize (GtkWidget *widget)
 
   attributes_mask = GDK_WA_VISUAL;
   attributes_mask |= (title ? GDK_WA_TITLE : 0);
-  attributes_mask |= (wmclass_name ? GDK_WA_WMCLASS : 0);
 
   if (gtk_widget_is_toplevel (widget))
     {
index c4e6aff897a390cdf25f2e226aa2a02a28542986..f6ddfa1b9675611dfeb84f9259fbe8df605f42d4 100644 (file)
@@ -203,7 +203,6 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
 
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.title = (gchar *) gtk_window_get_title (window);
-  _gtk_window_get_wmclass (window, &attributes.wmclass_name, &attributes.wmclass_class);
   attributes.width = allocation.width;
   attributes.height = allocation.height;
   attributes.wclass = GDK_INPUT_OUTPUT;
@@ -222,7 +221,6 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
 
   attributes_mask = GDK_WA_VISUAL;
   attributes_mask |= (attributes.title ? GDK_WA_TITLE : 0);
-  attributes_mask |= (attributes.wmclass_name ? GDK_WA_WMCLASS : 0);
 
   gdk_window = gdk_window_new (embed_widget->parent_window,
                                &attributes, attributes_mask);
index 937d42b758a9b835865c526f1768afd4c04055ba..205f471b625c465801a7b3f61d6cbe85f60cf170 100644 (file)
@@ -192,8 +192,6 @@ struct _GtkWindowPrivate
 
   gchar   *startup_id;
   gchar   *title;
-  gchar   *wmclass_class;
-  gchar   *wmclass_name;
   gchar   *wm_role;
 
   guint    keys_changed_handler;
@@ -1649,8 +1647,6 @@ gtk_window_init (GtkWindow *window)
   gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
 
   priv->title = NULL;
-  priv->wmclass_name = g_strdup (g_get_prgname ());
-  priv->wmclass_class = g_strdup (gdk_get_program_class ());
   priv->wm_role = NULL;
   priv->geometry_info = NULL;
   priv->type = GTK_WINDOW_TOPLEVEL;
@@ -2381,43 +2377,6 @@ gtk_window_get_title (GtkWindow *window)
   return window->priv->title;
 }
 
-/**
- * gtk_window_set_wmclass:
- * @window: a #GtkWindow
- * @wmclass_name: window name hint
- * @wmclass_class: window class hint
- *
- * Don’t use this function. It sets the X Window System “class” and
- * “name” hints for a window.  According to the ICCCM, you should
- * always set these to the same value for all windows in an
- * application, and GTK+ sets them to that value by default, so calling
- * this function is sort of pointless. However, you may want to call
- * gtk_window_set_role() on each window in your application, for the
- * benefit of the session manager. Setting the role allows the window
- * manager to restore window positions when loading a saved session.
- * 
- **/
-void
-gtk_window_set_wmclass (GtkWindow *window,
-                       const gchar *wmclass_name,
-                       const gchar *wmclass_class)
-{
-  GtkWindowPrivate *priv;
-
-  g_return_if_fail (GTK_IS_WINDOW (window));
-
-  priv = window->priv;
-
-  g_free (priv->wmclass_name);
-  priv->wmclass_name = g_strdup (wmclass_name);
-
-  g_free (priv->wmclass_class);
-  priv->wmclass_class = g_strdup (wmclass_class);
-
-  if (_gtk_widget_get_realized (GTK_WIDGET (window)))
-    g_warning ("gtk_window_set_wmclass: shouldn't set wmclass after window is realized!");
-}
-
 /**
  * gtk_window_set_role:
  * @window: a #GtkWindow
@@ -5820,8 +5779,6 @@ gtk_window_finalize (GObject *object)
   GtkMnemonicHash *mnemonic_hash;
 
   g_free (priv->title);
-  g_free (priv->wmclass_name);
-  g_free (priv->wmclass_class);
   g_free (priv->wm_role);
   gtk_window_release_application (window);
 
@@ -7139,8 +7096,6 @@ gtk_window_realize (GtkWidget *widget)
 #endif
 
       attributes.title = priv->title;
-      attributes.wmclass_name = priv->wmclass_name;
-      attributes.wmclass_class = priv->wmclass_class;
       attributes.wclass = GDK_INPUT_OUTPUT;
       attributes.visual = gtk_widget_get_visual (widget);
 
@@ -7169,7 +7124,6 @@ gtk_window_realize (GtkWidget *widget)
 
       attributes_mask |= GDK_WA_VISUAL | GDK_WA_TYPE_HINT;
       attributes_mask |= (priv->title ? GDK_WA_TITLE : 0);
-      attributes_mask |= (priv->wmclass_name ? GDK_WA_WMCLASS : 0);
 
       gdk_window = gdk_window_new (parent_window, &attributes, attributes_mask);
     }
@@ -11553,17 +11507,6 @@ gtk_window_set_focus_visible (GtkWindow *window,
     }
 }
 
-void
-_gtk_window_get_wmclass (GtkWindow  *window,
-                         gchar     **wmclass_name,
-                         gchar     **wmclass_class)
-{
-  GtkWindowPrivate *priv = window->priv;
-
-  *wmclass_name = priv->wmclass_name;
-  *wmclass_class = priv->wmclass_class;
-}
-
 /**
  * gtk_window_set_has_user_ref_count:
  * @window: a #GtkWindow
index 34b768137689a3e80471a53f50ed3ea490162313..1f1197a135c5ac0e0bc2dd5fce67c7221e247afc 100644 (file)
@@ -151,10 +151,6 @@ void       gtk_window_set_title                (GtkWindow           *window,
 GDK_AVAILABLE_IN_ALL
 const gchar * gtk_window_get_title             (GtkWindow           *window);
 GDK_AVAILABLE_IN_ALL
-void       gtk_window_set_wmclass              (GtkWindow           *window,
-                                               const gchar         *wmclass_name,
-                                               const gchar         *wmclass_class);
-GDK_AVAILABLE_IN_ALL
 void       gtk_window_set_role                 (GtkWindow           *window,
                                                 const gchar         *role);
 GDK_AVAILABLE_IN_ALL
index 5cb5a72db231125d96096bcb702fa17caf0ac0cd..20dbbda2a65ac1faa09aa8abfbe36bf9b91de1a4 100644 (file)
@@ -57,10 +57,6 @@ void            _gtk_window_set_is_active          (GtkWindow *window,
 void            _gtk_window_set_is_toplevel        (GtkWindow *window,
                                                     gboolean   is_toplevel);
 
-void            _gtk_window_get_wmclass            (GtkWindow  *window,
-                                                    gchar     **wmclass_name,
-                                                    gchar     **wmclass_class);
-
 void            _gtk_window_set_allocation         (GtkWindow           *window,
                                                     const GtkAllocation *allocation,
                                                     GtkAllocation       *allocation_out);